package org.springframework.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public abstract class StringUtils
{
  private static final String CURRENT_PATH = ".";
  private static final char EXTENSION_SEPARATOR = '.';
  private static final String FOLDER_SEPARATOR = "/";
  private static final String TOP_PATH = "..";
  private static final String WINDOWS_FOLDER_SEPARATOR = "\\";

  public static String[] addStringToArray(String[] paramArrayOfString, String paramString)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString))
      return new String[] { paramString };
    String[] arrayOfString = new String[1 + paramArrayOfString.length];
    System.arraycopy(paramArrayOfString, 0, arrayOfString, 0, paramArrayOfString.length);
    arrayOfString[paramArrayOfString.length] = paramString;
    return arrayOfString;
  }

  public static String applyRelativePath(String paramString1, String paramString2)
  {
    int i = paramString1.lastIndexOf("/");
    if (i != -1)
    {
      String str = paramString1.substring(0, i);
      if (!paramString2.startsWith("/"))
        str = str + "/";
      paramString2 = str + paramString2;
    }
    return paramString2;
  }

  public static String arrayToCommaDelimitedString(Object[] paramArrayOfObject)
  {
    return arrayToDelimitedString(paramArrayOfObject, ",");
  }

  public static String arrayToDelimitedString(Object[] paramArrayOfObject, String paramString)
  {
    if (ObjectUtils.isEmpty(paramArrayOfObject))
      return "";
    if (paramArrayOfObject.length == 1)
      return ObjectUtils.nullSafeToString(paramArrayOfObject[0]);
    StringBuilder localStringBuilder = new StringBuilder();
    for (int i = 0; ; i++)
    {
      if (i >= paramArrayOfObject.length)
        return localStringBuilder.toString();
      if (i > 0)
        localStringBuilder.append(paramString);
      localStringBuilder.append(paramArrayOfObject[i]);
    }
  }

  public static String capitalize(String paramString)
  {
    return changeFirstCharacterCase(paramString, true);
  }

  private static String changeFirstCharacterCase(String paramString, boolean paramBoolean)
  {
    if ((paramString == null) || (paramString.length() == 0))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString.length());
    if (paramBoolean)
      localStringBuilder.append(Character.toUpperCase(paramString.charAt(0)));
    while (true)
    {
      localStringBuilder.append(paramString.substring(1));
      return localStringBuilder.toString();
      localStringBuilder.append(Character.toLowerCase(paramString.charAt(0)));
    }
  }

  public static String cleanPath(String paramString)
  {
    if (paramString == null)
      return null;
    String str1 = replace(paramString, "\\", "/");
    int i = str1.indexOf(":");
    String str2 = "";
    if (i != -1)
    {
      str2 = str1.substring(0, i + 1);
      str1 = str1.substring(i + 1);
    }
    if (str1.startsWith("/"))
    {
      str2 = str2 + "/";
      str1 = str1.substring(1);
    }
    String[] arrayOfString = delimitedListToStringArray(str1, "/");
    LinkedList localLinkedList = new LinkedList();
    int j = 0;
    int k = -1 + arrayOfString.length;
    if (k < 0);
    for (int m = 0; ; m++)
    {
      if (m >= j)
      {
        return str2 + collectionToDelimitedString(localLinkedList, "/");
        String str3 = arrayOfString[k];
        if (!".".equals(str3))
        {
          if (!"..".equals(str3))
            break label185;
          j++;
        }
        while (true)
        {
          k--;
          break;
          label185: if (j > 0)
            j--;
          else
            localLinkedList.add(0, str3);
        }
      }
      localLinkedList.add(0, "..");
    }
  }

  public static String collectionToCommaDelimitedString(Collection paramCollection)
  {
    return collectionToDelimitedString(paramCollection, ",");
  }

  public static String collectionToDelimitedString(Collection paramCollection, String paramString)
  {
    return collectionToDelimitedString(paramCollection, paramString, "", "");
  }

  public static String collectionToDelimitedString(Collection paramCollection, String paramString1, String paramString2, String paramString3)
  {
    if (CollectionUtils.isEmpty(paramCollection))
      return "";
    StringBuilder localStringBuilder = new StringBuilder();
    Iterator localIterator = paramCollection.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return localStringBuilder.toString();
      localStringBuilder.append(paramString2).append(localIterator.next()).append(paramString3);
      if (localIterator.hasNext())
        localStringBuilder.append(paramString1);
    }
  }

  public static Set<String> commaDelimitedListToSet(String paramString)
  {
    TreeSet localTreeSet = new TreeSet();
    String[] arrayOfString = commaDelimitedListToStringArray(paramString);
    int i = arrayOfString.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return localTreeSet;
      localTreeSet.add(arrayOfString[j]);
    }
  }

  public static String[] commaDelimitedListToStringArray(String paramString)
  {
    return delimitedListToStringArray(paramString, ",");
  }

  public static String[] concatenateStringArrays(String[] paramArrayOfString1, String[] paramArrayOfString2)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString1))
      return paramArrayOfString2;
    if (ObjectUtils.isEmpty(paramArrayOfString2))
      return paramArrayOfString1;
    String[] arrayOfString = new String[paramArrayOfString1.length + paramArrayOfString2.length];
    System.arraycopy(paramArrayOfString1, 0, arrayOfString, 0, paramArrayOfString1.length);
    System.arraycopy(paramArrayOfString2, 0, arrayOfString, paramArrayOfString1.length, paramArrayOfString2.length);
    return arrayOfString;
  }

  public static boolean containsWhitespace(CharSequence paramCharSequence)
  {
    if (!hasLength(paramCharSequence));
    while (true)
    {
      return false;
      int i = paramCharSequence.length();
      for (int j = 0; j < i; j++)
        if (Character.isWhitespace(paramCharSequence.charAt(j)))
          return true;
    }
  }

  public static boolean containsWhitespace(String paramString)
  {
    return containsWhitespace(paramString);
  }

  public static int countOccurrencesOf(String paramString1, String paramString2)
  {
    if ((paramString1 == null) || (paramString2 == null) || (paramString1.length() == 0) || (paramString2.length() == 0))
    {
      i = 0;
      return i;
    }
    int i = 0;
    int k;
    for (int j = 0; ; j = k + paramString2.length())
    {
      k = paramString1.indexOf(paramString2, j);
      if (k == -1)
        break;
      i++;
    }
  }

  public static String delete(String paramString1, String paramString2)
  {
    return replace(paramString1, paramString2, "");
  }

  public static String deleteAny(String paramString1, String paramString2)
  {
    if ((!hasLength(paramString1)) || (!hasLength(paramString2)))
      return paramString1;
    StringBuilder localStringBuilder = new StringBuilder();
    for (int i = 0; ; i++)
    {
      if (i >= paramString1.length())
        return localStringBuilder.toString();
      char c = paramString1.charAt(i);
      if (paramString2.indexOf(c) == -1)
        localStringBuilder.append(c);
    }
  }

  public static String[] delimitedListToStringArray(String paramString1, String paramString2)
  {
    return delimitedListToStringArray(paramString1, paramString2, null);
  }

  public static String[] delimitedListToStringArray(String paramString1, String paramString2, String paramString3)
  {
    if (paramString1 == null)
      return new String[0];
    if (paramString2 == null)
      return new String[] { paramString1 };
    ArrayList localArrayList = new ArrayList();
    if ("".equals(paramString2))
      for (int k = 0; ; k++)
      {
        if (k >= paramString1.length())
          return toStringArray(localArrayList);
        localArrayList.add(deleteAny(paramString1.substring(k, k + 1), paramString3));
      }
    int j;
    for (int i = 0; ; i = j + paramString2.length())
    {
      j = paramString1.indexOf(paramString2, i);
      if (j == -1)
      {
        if ((paramString1.length() <= 0) || (i > paramString1.length()))
          break;
        localArrayList.add(deleteAny(paramString1.substring(i), paramString3));
        break;
      }
      localArrayList.add(deleteAny(paramString1.substring(i, j), paramString3));
    }
  }

  public static boolean endsWithIgnoreCase(String paramString1, String paramString2)
  {
    if ((paramString1 == null) || (paramString2 == null));
    do
    {
      return false;
      if (paramString1.endsWith(paramString2))
        return true;
    }
    while (paramString1.length() < paramString2.length());
    return paramString1.substring(paramString1.length() - paramString2.length()).toLowerCase().equals(paramString2.toLowerCase());
  }

  public static String getFilename(String paramString)
  {
    if (paramString == null)
      paramString = null;
    int i;
    do
    {
      return paramString;
      i = paramString.lastIndexOf("/");
    }
    while (i == -1);
    return paramString.substring(i + 1);
  }

  public static String getFilenameExtension(String paramString)
  {
    if (paramString == null);
    int i;
    do
    {
      return null;
      i = paramString.lastIndexOf('.');
    }
    while (i == -1);
    return paramString.substring(i + 1);
  }

  public static boolean hasLength(CharSequence paramCharSequence)
  {
    return (paramCharSequence != null) && (paramCharSequence.length() > 0);
  }

  public static boolean hasLength(String paramString)
  {
    return hasLength(paramString);
  }

  public static boolean hasText(CharSequence paramCharSequence)
  {
    if (!hasLength(paramCharSequence));
    while (true)
    {
      return false;
      int i = paramCharSequence.length();
      for (int j = 0; j < i; j++)
        if (!Character.isWhitespace(paramCharSequence.charAt(j)))
          return true;
    }
  }

  public static boolean hasText(String paramString)
  {
    return hasText(paramString);
  }

  public static String[] mergeStringArrays(String[] paramArrayOfString1, String[] paramArrayOfString2)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString1))
      return paramArrayOfString2;
    if (ObjectUtils.isEmpty(paramArrayOfString2))
      return paramArrayOfString1;
    ArrayList localArrayList = new ArrayList();
    localArrayList.addAll(Arrays.asList(paramArrayOfString1));
    int i = paramArrayOfString2.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return toStringArray(localArrayList);
      String str = paramArrayOfString2[j];
      if (!localArrayList.contains(str))
        localArrayList.add(str);
    }
  }

  public static Locale parseLocaleString(String paramString)
  {
    String[] arrayOfString = tokenizeToStringArray(paramString, "_ ", false, false);
    String str1;
    if (arrayOfString.length > 0)
    {
      str1 = arrayOfString[0];
      if (arrayOfString.length <= 1)
        break label103;
    }
    label103: for (String str2 = arrayOfString[1]; ; str2 = "")
    {
      String str3 = "";
      if (arrayOfString.length >= 2)
      {
        str3 = trimLeadingWhitespace(paramString.substring(paramString.indexOf(str2) + str2.length()));
        if (str3.startsWith("_"))
          str3 = trimLeadingCharacter(str3, '_');
      }
      if (str1.length() <= 0)
        break label109;
      return new Locale(str1, str2, str3);
      str1 = "";
      break;
    }
    label109: return null;
  }

  public static boolean pathEquals(String paramString1, String paramString2)
  {
    return cleanPath(paramString1).equals(cleanPath(paramString2));
  }

  public static String quote(String paramString)
  {
    if (paramString != null)
      return "'" + paramString + "'";
    return null;
  }

  public static Object quoteIfString(Object paramObject)
  {
    if ((paramObject instanceof String))
      paramObject = quote((String)paramObject);
    return paramObject;
  }

  public static String[] removeDuplicateStrings(String[] paramArrayOfString)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString))
      return paramArrayOfString;
    TreeSet localTreeSet = new TreeSet();
    int i = paramArrayOfString.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return toStringArray(localTreeSet);
      localTreeSet.add(paramArrayOfString[j]);
    }
  }

  public static String replace(String paramString1, String paramString2, String paramString3)
  {
    if ((!hasLength(paramString1)) || (!hasLength(paramString2)) || (paramString3 == null))
      return paramString1;
    StringBuilder localStringBuilder = new StringBuilder();
    int i = 0;
    int j = paramString1.indexOf(paramString2);
    int k = paramString2.length();
    while (true)
    {
      if (j < 0)
      {
        localStringBuilder.append(paramString1.substring(i));
        return localStringBuilder.toString();
      }
      localStringBuilder.append(paramString1.substring(i, j));
      localStringBuilder.append(paramString3);
      i = j + k;
      j = paramString1.indexOf(paramString2, i);
    }
  }

  public static String[] sortStringArray(String[] paramArrayOfString)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString))
      return new String[0];
    Arrays.sort(paramArrayOfString);
    return paramArrayOfString;
  }

  public static String[] split(String paramString1, String paramString2)
  {
    if ((!hasLength(paramString1)) || (!hasLength(paramString2)));
    int i;
    do
    {
      return null;
      i = paramString1.indexOf(paramString2);
    }
    while (i < 0);
    return new String[] { paramString1.substring(0, i), paramString1.substring(i + paramString2.length()) };
  }

  public static Properties splitArrayElementsIntoProperties(String[] paramArrayOfString, String paramString)
  {
    return splitArrayElementsIntoProperties(paramArrayOfString, paramString, null);
  }

  public static Properties splitArrayElementsIntoProperties(String[] paramArrayOfString, String paramString1, String paramString2)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString))
    {
      localProperties = null;
      return localProperties;
    }
    Properties localProperties = new Properties();
    int i = paramArrayOfString.length;
    int j = 0;
    label26: String[] arrayOfString;
    if (j < i)
    {
      String str = paramArrayOfString[j];
      if (paramString2 != null)
        str = deleteAny(str, paramString2);
      arrayOfString = split(str, paramString1);
      if (arrayOfString != null)
        break label70;
    }
    while (true)
    {
      j++;
      break label26;
      break;
      label70: localProperties.setProperty(arrayOfString[0].trim(), arrayOfString[1].trim());
    }
  }

  public static boolean startsWithIgnoreCase(String paramString1, String paramString2)
  {
    if ((paramString1 == null) || (paramString2 == null));
    do
    {
      return false;
      if (paramString1.startsWith(paramString2))
        return true;
    }
    while (paramString1.length() < paramString2.length());
    return paramString1.substring(0, paramString2.length()).toLowerCase().equals(paramString2.toLowerCase());
  }

  public static String stripFilenameExtension(String paramString)
  {
    if (paramString == null)
      paramString = null;
    int i;
    do
    {
      return paramString;
      i = paramString.lastIndexOf('.');
    }
    while (i == -1);
    return paramString.substring(0, i);
  }

  public static boolean substringMatch(CharSequence paramCharSequence1, int paramInt, CharSequence paramCharSequence2)
  {
    for (int i = 0; ; i++)
    {
      if (i >= paramCharSequence2.length())
        return true;
      int j = paramInt + i;
      if ((j >= paramCharSequence1.length()) || (paramCharSequence1.charAt(j) != paramCharSequence2.charAt(i)))
        return false;
    }
  }

  public static String toLanguageTag(Locale paramLocale)
  {
    StringBuilder localStringBuilder = new StringBuilder(String.valueOf(paramLocale.getLanguage()));
    if (hasText(paramLocale.getCountry()));
    for (String str = "-" + paramLocale.getCountry(); ; str = "")
      return str;
  }

  public static String[] toStringArray(Collection<String> paramCollection)
  {
    if (paramCollection == null)
      return null;
    return (String[])paramCollection.toArray(new String[paramCollection.size()]);
  }

  public static String[] toStringArray(Enumeration<String> paramEnumeration)
  {
    if (paramEnumeration == null)
      return null;
    ArrayList localArrayList = Collections.list(paramEnumeration);
    return (String[])localArrayList.toArray(new String[localArrayList.size()]);
  }

  public static String[] tokenizeToStringArray(String paramString1, String paramString2)
  {
    return tokenizeToStringArray(paramString1, paramString2, true, true);
  }

  public static String[] tokenizeToStringArray(String paramString1, String paramString2, boolean paramBoolean1, boolean paramBoolean2)
  {
    if (paramString1 == null)
      return null;
    StringTokenizer localStringTokenizer = new StringTokenizer(paramString1, paramString2);
    ArrayList localArrayList = new ArrayList();
    while (true)
    {
      if (!localStringTokenizer.hasMoreTokens())
        return toStringArray(localArrayList);
      String str = localStringTokenizer.nextToken();
      if (paramBoolean1)
        str = str.trim();
      if ((!paramBoolean2) || (str.length() > 0))
        localArrayList.add(str);
    }
  }

  public static String trimAllWhitespace(String paramString)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    int i = 0;
    while (true)
    {
      if (localStringBuilder.length() <= i)
        return localStringBuilder.toString();
      if (Character.isWhitespace(localStringBuilder.charAt(i)))
        localStringBuilder.deleteCharAt(i);
      else
        i++;
    }
  }

  public static String[] trimArrayElements(String[] paramArrayOfString)
  {
    if (ObjectUtils.isEmpty(paramArrayOfString))
    {
      arrayOfString = new String[0];
      return arrayOfString;
    }
    String[] arrayOfString = new String[paramArrayOfString.length];
    int i = 0;
    label22: String str1;
    if (i < paramArrayOfString.length)
    {
      str1 = paramArrayOfString[i];
      if (str1 == null)
        break label53;
    }
    label53: for (String str2 = str1.trim(); ; str2 = null)
    {
      arrayOfString[i] = str2;
      i++;
      break label22;
      break;
    }
  }

  public static String trimLeadingCharacter(String paramString, char paramChar)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    while (true)
    {
      if ((localStringBuilder.length() <= 0) || (localStringBuilder.charAt(0) != paramChar))
        return localStringBuilder.toString();
      localStringBuilder.deleteCharAt(0);
    }
  }

  public static String trimLeadingWhitespace(String paramString)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    while (true)
    {
      if ((localStringBuilder.length() <= 0) || (!Character.isWhitespace(localStringBuilder.charAt(0))))
        return localStringBuilder.toString();
      localStringBuilder.deleteCharAt(0);
    }
  }

  public static String trimTrailingCharacter(String paramString, char paramChar)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    while (true)
    {
      if ((localStringBuilder.length() <= 0) || (localStringBuilder.charAt(-1 + localStringBuilder.length()) != paramChar))
        return localStringBuilder.toString();
      localStringBuilder.deleteCharAt(-1 + localStringBuilder.length());
    }
  }

  public static String trimTrailingWhitespace(String paramString)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    while (true)
    {
      if ((localStringBuilder.length() <= 0) || (!Character.isWhitespace(localStringBuilder.charAt(-1 + localStringBuilder.length()))))
        return localStringBuilder.toString();
      localStringBuilder.deleteCharAt(-1 + localStringBuilder.length());
    }
  }

  public static String trimWhitespace(String paramString)
  {
    if (!hasLength(paramString))
      return paramString;
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    if ((localStringBuilder.length() <= 0) || (!Character.isWhitespace(localStringBuilder.charAt(0))));
    while (true)
    {
      if ((localStringBuilder.length() <= 0) || (!Character.isWhitespace(localStringBuilder.charAt(-1 + localStringBuilder.length()))))
      {
        return localStringBuilder.toString();
        localStringBuilder.deleteCharAt(0);
        break;
      }
      localStringBuilder.deleteCharAt(-1 + localStringBuilder.length());
    }
  }

  public static String uncapitalize(String paramString)
  {
    return changeFirstCharacterCase(paramString, false);
  }

  public static String unqualify(String paramString)
  {
    return unqualify(paramString, '.');
  }

  public static String unqualify(String paramString, char paramChar)
  {
    return paramString.substring(1 + paramString.lastIndexOf(paramChar));
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     org.springframework.util.StringUtils
 * JD-Core Version:    0.6.2
 */